# Build recipe for jwm
#
# Copyright 2017 Mateus P. Rodrigues <mprodrigues@dragora.org>.
#
# This recipe is free software, under the terms of the Apache License 2.0

program=jwm
version=2.3.7
release=1

tarname=${program}-${version}.tar.xz

# Remote source(s)
fetch=https://joewing.net/projects/jwm/releases/$tarname

description="
JWM - Joe's Windowm Manager

JWM is a light-weight window manager for the X11 Window System. JWM is written
in C and uses only Xlib at a minimum. Because of its small footprint, JWM makes
a good window manager for older computers and less powerful systems, such as the
Raspberry Pi, though it is perfectly capable of running on modern systems.
"

homepage=https://joewing.net/projects/jwm/
license=MIT

# Source documentation
docs="ABOUT-NLS CONTRIBUTING.md ChangeLog LICENSE README*"
docsdir="${docdir}/${program}-${version}"

build()
{
    set -e

    unpack "${tardir}/$tarname"

    cd "$srcdir"

    ./configure CFLAGS="$QICFLAGS" LDFLAGS="$QILDFLAGS" \
     $configure_args \
     --libdir=/usr/lib${libSuffix} \
     --infodir=$infodir \
     --mandir=$mandir \
     --docdir=$docdir \
     --build="$(cc -dumpmachine)"

    make -j${jobs} V=1
    make -j${jobs} DESTDIR="$destdir" install

    # Compress and link man pages (if needed)
    if test -d "${destdir}/$mandir"
    then
        (
            cd "${destdir}/$mandir"
            find . -type f -exec lzip -9 '{}' +
            find . -type l | while read -r file
            do
                ln -sf "$(readlink -- "$file").lz" "${file}.lz"
                rm -- "$file"
            done
        )
    fi

    # Copy documentation
    mkdir -p "${destdir}${docsdir}"
    cp -p $docs "${destdir}${docsdir}"
}
